#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(1ll*x*y>=0)
			puts("0");
		else
			printf("%d\n",min(min(abs(x),abs(y)),abs(x+y)));
	}
	return 0;
}
